<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            min-width: 1226px;
            height: 520px;
            background-image: url('./img/baidu4.jpg');
            background-size: 100%;
            background-repeat: no-repeat;
        }
        .clearfix::after,
        .clearfix::before{
            content: '';
            display: table;
            clear: both;
        }
        .baidu{
            width: 410px;
            padding: 2px;
            background-color: #fff;
            margin: 150px auto;
        }
        .baidu li{
            padding-top:3px ;
            list-style: none;
            float: left;
            margin: 0 1px;
        }
        .baidu img{
            width: 100px;
        }
    </style>
</head>
<body class="clearfix">
    <ul class="baidu clearfix">
        <li><img src="./img/baidu1.jpg" alt=""></li>
        <li><img src="./img/baidu2.jpg" alt=""></li>
        <li><img src="./img/baidu3.jpg" alt=""></li>
        <li><img src="./img/baidu4.jpg" alt=""></li>
    </ul>
    <script>
        //首先获取全部li
        var imgs = document.querySelector('.baidu').querySelectorAll('img');
        for(var i = 0; i < imgs.length;i++){
            imgs[i].onclick = function(){
                console.log(this.src);
                //把这个src给body
                document.body.style.backgroundImage = 'url('+this.src+')';
            }
        }
    </script>
</body>

</html>